/*
 * Copyright 2011 Stefan Ferstl
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.code.debmavenplugin.archiver.ar;

import java.io.File;

import org.apache.commons.compress.archivers.ar.ArArchiveEntry;

import com.google.code.debmavenplugin.archiver.IFileArchiveEntry;


/**
 * {@link ArArchiveEntry} that enforces the usage of {@link File} objects.
 */
public class FileArArchiveEntry extends ArArchiveEntry implements IFileArchiveEntry {

  private final File inputFile;

  /**
   * Constructor.
   *
   * @param inputFile
   * @param name The name of the archived file in the archive.
   * @param userId The user ID of the file.
   * @param groupId The group ID of the file.
   * @param mode The (UNIX) file mode.
   * @param lastModified The date when the file was last modified.
   */
  public FileArArchiveEntry(File inputFile, String name, int userId, int groupId, int mode, long lastModified) {
    super(name, inputFile.length(), userId, groupId, mode, lastModified);
    this.inputFile = inputFile;
  }

  /**
   * Constructor.
   *
   * @param inputFile The file to archive.
   * @param entryName The name of the archived file in the archive.
   */
  public FileArArchiveEntry(File inputFile, String entryName) {
    super(inputFile, entryName);
    this.inputFile = inputFile;
  }

  /**
   * Constructor.
   *
   * @param inputFile
   * @param name The name of the archived file in the archive.
   * @param length The length of the file to be archived.
   */
  public FileArArchiveEntry(File inputFile, String name, long length) {
    super(name, length);
    this.inputFile = inputFile;
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public boolean isDirectory() {
    return this.inputFile.isDirectory();
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public File getFile() {
    return this.inputFile;
  }

}
